<template>
  <div class="guidescores">
    <el-table
      :data="guideInfoArr"
      border
      style="width: 100%"
      :header-cell-style="{ textAlign: 'center' }"
      :cell-style="{ textAlign: 'center' }"
    >
      <el-table-column type="index" label="序号" width="50"> </el-table-column>
      <el-table-column prop="userName" label="导游姓名" width="360">
      </el-table-column>
      <el-table-column prop="userNumber" label="导游工号" width="360">
      </el-table-column>
      <el-table-column prop="userId" label="导游id" width="360">
      </el-table-column>
      <el-table-column label="操作" width="127">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click="queryscore(scope.row.userId)"
            >查看总分</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 15, 20, 25]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totals"
      >
      </el-pagination>
    </div>

    <el-dialog
      title="导游总评分"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-rate
        v-model="value"
        disabled
        show-score
        text-color="#ff9900"
        score-template="{value}"
      >
      </el-rate>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { tourInfoApi, tourevaluation } from "@network/api/score.js";
export default {
  data() {
    return {
      guideInfoArr: [],
      currentPage: 1,
      pageSize: 10,
      totals: 0,
      dialogVisible: false,
      value:0
    };
  },
  methods: {
    handleCurrentChange(val) {
      this.currentPage = val;
      this.tourInfoApiFun();
    },
    handleSizeChange(val) {
      this.currentPage = 1;
      this.pageSize = val;
      this.tourInfoApiFun();
    },
    async tourInfoApiFun() {
      let restourInfoApi = await tourInfoApi(this.currentPage, this.pageSize);
      console.log("restourInfoApi", restourInfoApi);
      let { userDaoyouVOS, total } = restourInfoApi.data.data;
      this.guideInfoArr = userDaoyouVOS;
      this.totals = total;
    },
    queryscore(val) {
      this.dialogVisible = true;
      console.log("总评分", val);
      this.tourevaluationFun(val);
    },
    async tourevaluationFun(val) {
      let restourevaluation = await tourevaluation(val);
      console.log("星星", restourevaluation.data.data.starEvaluation);
      this.value=restourevaluation.data.data.starEvaluation
    },
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
  },
  created() {
    this.tourInfoApiFun();
  },
};
</script>

<style scoped lang="scss">
.guidescores {
  background-color: #fff;
  height: 100vh;
  padding: 40px 20px;
}
.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
</style>